.class final Lcom/zuiapps/suite/utils/process/PSHelper$1;
.super Ljava/lang/Thread;
.source "PSHelper.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/zuiapps/suite/utils/process/PSHelper;->isProcessRunning(Ljava/lang/String;Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = null
.end annotation


# instance fields
.field final synthetic val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

.field final synthetic val$pName:Ljava/lang/String;


# direct methods
.method constructor <init>(Ljava/lang/String;Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;)V
    .registers 3

    .prologue
    .line 79
    iput-object p1, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$pName:Ljava/lang/String;

    iput-object p2, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    return-void
.end method


# virtual methods
.method public run()V
    .registers 11

    .prologue
    .line 81
    const-string v8, "(\\d+).+?\\s+[DNRSTZ]\\s+(.+)$"

    invoke-static {v8}, Ljava/util/regex/Pattern;->compile(Ljava/lang/String;)Ljava/util/regex/Pattern;

    move-result-object v5

    .line 82
    .local v5, "pidPattern":Ljava/util/regex/Pattern;
    new-instance v4, Ljava/util/HashMap;

    invoke-direct {v4}, Ljava/util/HashMap;-><init>()V

    .line 85
    .local v4, "pidNames":Ljava/util/Map;, "Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;"
    :try_start_b
    invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;

    move-result-object v8

    const-string v9, "ps"

    invoke-virtual {v8, v9}, Ljava/lang/Runtime;->exec(Ljava/lang/String;)Ljava/lang/Process;

    move-result-object v6

    .line 86
    .local v6, "process":Ljava/lang/Process;
    new-instance v0, Ljava/io/BufferedReader;

    new-instance v8, Ljava/io/InputStreamReader;

    invoke-virtual {v6}, Ljava/lang/Process;->getInputStream()Ljava/io/InputStream;

    move-result-object v9

    invoke-direct {v8, v9}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;)V

    invoke-direct {v0, v8}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;)V

    .line 89
    .local v0, "bufferedReader":Ljava/io/BufferedReader;
    :cond_23
    :goto_23
    invoke-virtual {v0}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;

    move-result-object v1

    .local v1, "line":Ljava/lang/String;
    if-eqz v1, :cond_3f

    .line 90
    invoke-virtual {v5, v1}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;

    move-result-object v2

    .line 91
    .local v2, "matcher":Ljava/util/regex/Matcher;
    invoke-virtual {v2}, Ljava/util/regex/Matcher;->find()Z

    move-result v8

    if-eqz v8, :cond_23

    .line 92
    const/4 v8, 0x2

    invoke-virtual {v2, v8}, Ljava/util/regex/Matcher;->group(I)Ljava/lang/String;

    move-result-object v3

    .line 93
    .local v3, "name":Ljava/lang/String;
    const/4 v8, 0x0

    invoke-interface {v4, v3, v8}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    goto :goto_23

    .line 109
    .end local v0    # "bufferedReader":Ljava/io/BufferedReader;
    .end local v1    # "line":Ljava/lang/String;
    .end local v2    # "matcher":Ljava/util/regex/Matcher;
    .end local v3    # "name":Ljava/lang/String;
    .end local v6    # "process":Ljava/lang/Process;
    :catch_3d
    move-exception v8

    .line 111
    :goto_3e
    return-void

    .line 97
    .restart local v0    # "bufferedReader":Ljava/io/BufferedReader;
    .restart local v1    # "line":Ljava/lang/String;
    .restart local v6    # "process":Ljava/lang/Process;
    :cond_3f
    iget-object v7, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$pName:Ljava/lang/String;

    .line 98
    .local v7, "processName":Ljava/lang/String;
    invoke-interface {v4, v7}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z

    move-result v8

    if-nez v8, :cond_58

    .line 99
    iget-object v8, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

    if-eqz v8, :cond_51

    .line 100
    iget-object v8, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

    const/4 v9, 0x0

    invoke-interface {v8, v9}, Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;->callback(Z)V

    .line 107
    :cond_51
    :goto_51
    invoke-virtual {v0}, Ljava/io/BufferedReader;->close()V

    .line 108
    invoke-virtual {v6}, Ljava/lang/Process;->destroy()V

    goto :goto_3e

    .line 103
    :cond_58
    iget-object v8, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

    if-eqz v8, :cond_51

    .line 104
    iget-object v8, p0, Lcom/zuiapps/suite/utils/process/PSHelper$1;->val$daemonCallback:Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;

    const/4 v9, 0x1

    invoke-interface {v8, v9}, Lcom/zuiapps/suite/utils/process/PSHelper$DaemonCallback;->callback(Z)V
    :try_end_62
    .catch Ljava/io/IOException; {:try_start_b .. :try_end_62} :catch_3d

    goto :goto_51
.end method
